{% extends "base.html" %}
{% block title %}{% endblock %}
{% block content %}
<br>

<form class="layui-form" action="" id="cross_srh">
    <div class="proxy_srh">
        <div class="layui-inline">
            <div class="layui-inline">

               <div class="layui-input-inline">
                    <label class="layui-form-label">project_name：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="project_id" id="project_id" lay-verify="" lay-search
                                lay-filter="project_id">

                            {% for d in projectAll %}
                                <option value="{{d.id}}">{{d.project_name}}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">moudle_type：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="moudle_type" id="moudle_type" lay-verify="" lay-search
                                lay-filter="moudle_type">
                            <option value="1">供API使用</option>

                        </select>
                    </div>
                </div>

                <div class="layui-inline" style="left: 10px">
                    <button class="layui-btn" type="button" id="start" lay-submit lay-filter="start">查询</button>
                </div>
            </div>
        </div>

    </div>
</form>
<hr class="layui-bg-gray">
<button class="layui-btn  layui-btn-normal" id="add" type="button">
    <i class="layui-icon"></i> 创建模块
</button>

<script type="text/html" id="filemange_v1">
    <button type="button"  class="layui-btn layui-btn-xs layui-btn-danger" lay-event="getNode">更新</button>
</script>

<table class="layui-hide" id="moduleCache" lay-filter="moduleCache"></table>
<script>
    layui.use(['table','code'], function(){
          var table = layui.table
          ,form = layui.form;
          var $= layui.jquery;
          var loading = layer.load();
          var  options = {
                elem:'#moduleCache',
                skin:"line",
                page:true,
                limit:10,
                limits:[10,20,30],
                height: 'full-200',
                toolbar: true,
                url:'/moudle/srh',
                where:{
                    project_id : $('#project_id option:selected').val(),
                    moudle_type: $('#moudle_type option:selected').val(),
                },
                response:{
                    statusName:'errorCode',
                    statusCode:'',
                    dataName:'data'
                },
                cols:[[
                      {field: 'id', title: 'id',sort:true,width:80}
                      ,{field: 'moudle_name', title: 'moudle_name',sort:true}
                      ,{field: 'moudle_type', title: 'moudle_type',sort:true,templet: function(d){
                            if(d.moudle_type == "1"){
                                return "供API使用";
                            } else if(d.moudle_type == "2"){
                                return "供Load使用";
                            } else if(d.moudle_type == "3"){
                                return "供Case使用";
                            }

                      }}
                      ,{field: 'last_time', title: 'last_time',sort:true}
                      ,{fixed: 'right', title:'', toolbar: '#filemange_v1',width:150}

                ]],
                id:'moduleCache',
                done:function(res,cur,count){
                    layer.close(loading);
                }
              };
          var tableIns = table.render(options);

          //点击查询
          $('#start').on('click',function(){
              var loading = layer.load();

              options = {
                elem:'#moduleCache',
                skin:"line",
                page:true,
                limit:10,
                limits:[10,20,30],
                height: 'full-200',
                toolbar: true,
                url:'/moudle/srh',
                where:{
                    project_id : $('#project_id option:selected').val(),
                    moudle_type: $('#moudle_type option:selected').val(),
                },
                response:{
                    statusName:'errorCode',
                    statusCode:'',
                    dataName:'data'
                }
              }
              tableIns.reload(options);
              layer.close(loading);
          });

          //点击添加页面

          $('#add').on('click',function(){
                layui.data('test', {key: 'moudelDCase',value: undefined});

                layer.open({
                            type:2,
                            content:'/moudle/index/manage?token={{token}}&openId={{openId}}',
                            area:['476px','275px'],
                            //offset: ['231px','307px'],
                            title:"维护模块",
                            closeBtn:1,
                            shade: 0,
                            shadeClose:true,
                            cancel: function(index, layero){
                                tableIns.reload(options);
                            }
                });
                return false;

          });
          table.on('row(moduleCache)', function(obj){
                obj.tr.css("background","#eeeeee");
          });

          table.on('tool(moduleCache)', function(obj){

                if(obj.event === 'getNode'){
                    layui.data('test', {key: 'moudelDCase',value: obj.data});
                    layer.open({
                            type:2,
                            content:'/moudle/index/manage?token={{token}}&openId={{openId}}',
                            area:['476px','275px'],
                            //offset: ['231px','307px'],
                            title:"维护模块",
                            closeBtn:1,
                            shade: 0,
                            shadeClose:true,
                            cancel: function(index, layero){
                                tableIns.reload(options);
                            }
                });
                }
                return false;

          });

          form.render();
          layer.close(loading);
    });
</script>

{% endblock %}